using System;
using System.Collections.Generic;
using UnityEngine;
using Core.Runtime;

namespace Core.Runtime
{
    /// <summary>
    /// Asset资源组件
    /// </summary>
    public class AssetLifecycle : MonoBehaviour
    {
        private void Awake()
        {
            AssetManager.UnloadBundleDelayTime = GameSettings.UnloadBundleDelay;
            AssetManager.UnloadAssetDelayTime = GameSettings.UnloadAssetDelay;
            AssetManager.MaxTaskRunCount = GameSettings.MaxConcurrentTasks;

#if UNITY_EDITOR
            if (GameSettings.IsEditorMode)
            {
                AssetManager.SetAssetLoader<EditorAssetLoader>();
                return;
            }
#endif
            switch (GameSettings.RuntimeMode)
            {
                case RuntimeMode.PackageOnly:
                    AssetManager.SetAssetLoader<PackageOnlyAssetLoader>();
                    break;
                case RuntimeMode.Updatable:
                    AssetManager.SetAssetLoader<UpdatableAssetLoader>();
                    break;
            }
        }

        private void Update()
        {
            AssetManager.Update();
        }
    }
}
